<nav class="navbar navbar-expand-lg navbar-light bg-light">
    <a class="navbar-brand" href="{% url 'index' %}">YuriX</a>
    {% block 'header-title' %}{% endblock %}
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>
  {% if request.user.is_authenticated %}
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav mr-auto">
        <li class="nav-item active">
          <a class="nav-link" href="{% url 'index'%}">尤里X <span class="sr-only">(current)</span></a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="{% url 'cart'%}">购物车<span class="badge badge-pill badge-secondary">{{request.user.cart.items.count}}</span>
          </a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="{% url 'orders'%}">订单<span class="badge badge-pill badge-secondary">{{request.user.order_set.count}}</span>
          </a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="{% url 'address'%}">地址<span class="badge badge-pill badge-secondary">{{request.user.address_set.count}}</span>
          </a>
        </li>
      </ul>
      <div class='btn-group'>
        <a class="btn btn-link" href="{% url 'user'%}">{{request.user.username}}</a>
        <a class="btn btn-link" href="{% url 'logout'%}">退出</a>
      </div>
    </div>
  {% else %}
  <div class="collapse navbar-collapse" id="navbarSupportedContent">
    <ul class="navbar-nav mr-auto">
      <li class="nav-item active">
        <a class="nav-link" href="{% url 'index'%}">主页 <span class="sr-only">(current)</span></a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="{% url 'cart'%}">购物车<span class="badge badge-pill badge-secondary">0</span>
        </a>
      </li>
    </ul>
    <div class='btn-group'>
      <a class="btn btn-link" href="{% url 'login'%}">登录</a>
    </div>
  </div>
  {% endif %}
  </nav>